/**
 * @description 生成随机列表
 * @param {number} min 列表最小长度
 * @param {number} max  列表最大长度
 * @returns {string[]} 随机列表
 */
const getRandomList = (min: number, max: number): string[] => new Array(Math.floor(Math.random() * (max - min + 1) + min)).fill('')

const generateRandomString = (length: number, firstChar: string): string => {
  let result = firstChar
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  for (let i = 0; i < length; i++) {
    const randomIndex = Math.floor(Math.random() * characters.length)
    result += characters.charAt(randomIndex)
  }
  return result
}

const charCodeOfA = 'A'.charCodeAt(0)

export const groups = Array(26)
  .fill('')
  .map((_, i) => ({
    title: String.fromCharCode(charCodeOfA + i),
    items: getRandomList(3, 10).map(() => generateRandomString(12, String.fromCharCode(charCodeOfA + i))),
  }))
